<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新闻管理-新闻编辑</title>
    <!-- layui.css -->
    <link href="/libs/layui/css/layui.css" rel="stylesheet">
    <script src="/libs/jquery.js"></script>
    <!-- layui.js -->
    <script src="/libs/layui/layui.js"></script>
    <script src="/libs/axios.js"></script>
    <!-- 引入在线文本编辑器 -->
    <script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>
</head>

<body>
    <form class="layui-form" action="" style="margin-top:5px">
        <!-- 隐藏域保存要修改的新闻id -->
        <input type="hidden" name="id" value="{{article.id}}">
        <div class="layui-form-item">
            <label class="layui-form-label">新闻标题</label>
            <div class="layui-input-inline" style="width:400px">
                <input type="text" name="title" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="{{article.title}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新闻图片</label>
            <div class="layui-input-inline" style="width:400px">
                <button type="button" class="layui-btn" id="test1">
                  <i class="layui-icon">&#xe67c;</i>上传图片
                 </button>
                <!-- 预览上传成功的图片 -->
                <span style="display:inline-block;width:50px;height:50px;">
                     <img style="width:100%;height: 100%;object-fit: cover;" src="{{article.picture}}" alt="" id="preview_picture">
                </span>

                <!-- 隐藏域保存上传成功的图片地址 -->
                <input lay-verify="checkPicture" type="hidden" id="upload_picture" name="picture" value="{{article.picture}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属分类</label>
            <div class="layui-input-inline" style="width:400px">
                <select name="cate_id" lay-verify="required|number">
                  {{each cates v}}
                    {{if article.cate_id===v.id}}
                     <option selected value="{{v.id}}">{{v.cate_name}}</option>
                    {{else /}}
                      <option  value="{{v.id}}">{{v.cate_name}}</option>
                    {{/if}}
                  {{/each}}
               </select>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">新闻内容</label>
            <!-- 层级设置低，避免挡住下拉菜单选项 -->
            <div class="layui-input-inline" style="width:600px;z-index: 0;">
                <div id="content"></div>
                <!-- textarea获取在线文本编辑器的数据，并通过name属性进行数据提交 -->
                <textarea lay-verify="checkContent" id="text1" style="display:none;" name="content" placeholder="请输入内容" class="layui-textarea">{{article.content}}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新闻添加人</label>
            <div class="layui-input-inline" style="width:400px">
                <input type="text" name="author" lay-verify="required" placeholder="请输入作者" autocomplete="off" class="layui-input" value="{{article.author}}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即修改</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="/js/news/news_update.js"></script>
</body>

</html>